Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.IO

Namespace C4F.DevKit.WebServicesDemo
	Public Partial Class DiggControl
		Inherits UserControl
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub DiggGrid_CellContentClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DiggGrid.CellContentClick
			Dim Cells As DataGridViewSelectedCellCollection = DiggGrid.SelectedCells
			If TypeOf Cells(0) Is System.Windows.Forms.DataGridViewLinkCell Then
				Dim LinkCell As DataGridViewLinkCell = CType(Cells(0), DataGridViewLinkCell)
				Dim BrowserForm As DemoBrowser = New DemoBrowser(CStr(LinkCell.Value))
				BrowserForm.Show()
			End If
		End Sub

		Private Sub GoButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles GoButton.Click
            Try
                DiggResults = DiggService.GetHeadlines_DS()
                DiggGrid.DataSource = DiggResults
            Catch ex As System.Net.WebException
                Dim streamReader As StreamReader = New StreamReader(ex.Response.GetResponseStream())
                Dim responseData As String = streamReader.ReadToEnd()
                streamReader.Close()
                MessageBox.Show(responseData)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub
    End Class
End Namespace
